package com.dt.platform.generator.module.oa;

import com.dt.platform.constants.db.OaTables;
import com.dt.platform.generator.config.Config;
import com.dt.platform.oa.page.ProjectRcdPageController;
import com.dt.platform.proxy.oa.ProjectRcdServiceProxy;
import com.github.foxnic.generator.config.WriteMode;
import org.github.foxnic.web.domain.hrm.Employee;
import org.github.foxnic.web.domain.storage.File;

public class AProjectRcdGtr extends BaseCodeGenerator {


    public AProjectRcdGtr() {
        super(OaTables.OA_PROJECT_RCD.$TABLE,"705020984087805957");
    }

    public void generateCode() throws Exception {
        System.out.println(this.getClass().getName());

        cfg.view().field(OaTables.OA_PROJECT_RCD.ID).basic().hidden(true);
        cfg.view().field(OaTables.OA_PROJECT_RCD.CONTENT).search().fuzzySearch();

        cfg.getPoClassFile().addSimpleProperty(Employee.class,"owner","owner","owner");

        cfg.view().search().inputLayout(
                new Object[]{
                        OaTables.OA_PROJECT_RCD.CONTENT,
                }
        );


        cfg.view().field(OaTables.OA_PROJECT_RCD.UPDATE_BY).table().disable(true);
        cfg.view().field(OaTables.OA_PROJECT_RCD.UPDATE_BY).table().disable(true);
        cfg.view().field(OaTables.OA_PROJECT_RCD.CREATE_BY).table().disable(true);
        cfg.view().field(OaTables.OA_PROJECT_RCD.OWNER_ID).table().disable(true);
        cfg.view().field(OaTables.OA_PROJECT_RCD.OWNER_TYPE).table().disable(true);
        cfg.view().list().disableBatchDelete();

        cfg.view().search().labelWidth(1,Config.searchLabelWidth);
        cfg.view().search().labelWidth(2,Config.searchLabelWidth);
        cfg.view().search().labelWidth(3,Config.searchLabelWidth);
        cfg.view().search().labelWidth(4,Config.searchLabelWidth);
        cfg.view().search().inputWidth(Config.searchInputWidth);

        cfg.view().form().labelWidth(88);
        cfg.view().field(OaTables.OA_PROJECT_RCD.USER_ID).table().fillBy("owner","name");
        cfg.view().field(OaTables.OA_PROJECT_RCD.USER_ID).form()
                .button().chooseEmployee(true);



        cfg.view().form().addGroup(null,
                new Object[] {
                        OaTables.OA_PROJECT_RCD.CONTENT,
                }
        );

        cfg.view().list().addJsVariable("OWNER_ID","[[${ownerId}]]","ownerId");



        //文件生成覆盖模式
        cfg.overrides()
                .setServiceIntfAnfImpl(WriteMode.IGNORE) //服务与接口
                .setControllerAndAgent(WriteMode.IGNORE) //Rest
                .setPageController(WriteMode.IGNORE) //页面控制器
                .setFormPage(WriteMode.COVER_EXISTS_FILE) //表单HTML页
                .setListPage(WriteMode.COVER_EXISTS_FILE)
                .setExtendJsFile(WriteMode.IGNORE); //列表HTML页

        //生成代码
        cfg.buildAll();
    }

    public static void main(String[] args) throws Exception {
        AProjectRcdGtr g=new AProjectRcdGtr();
        //生成代码
        g.generateCode();

        //移除之前生成的菜单，视情况执行
//        g.removeByBatchId("471622036347682816");
        //生成菜单
     //   g.generateMenu(ProjectRcdServiceProxy.class, ProjectRcdPageController.class);
    }

}
